// IMPORTANT
// Cannot reference to src folder. It would fail in release mode.
// import { IpcMessageConstant } from '../src/app/core/constants/ipc-message.constant';

const { app, dialog, ipcMain } = require('electron');

export class ElectronService {
    static readonly IpcMessageGetPath: string = 'get-path';

    static setupIpc(): void {
        ipcMain.on(ElectronService.IpcMessageGetPath, (event, arg) => {
            event.returnValue = app.getPath(arg);
        });

        // Asynchronous message example.
        // ipcMain.on('asynchronous-message', (event, arg) => {
        //     console.log(arg) // prints "ping"
        //     event.reply('asynchronous-reply', 'pong')
        // })
        // 
        // ipcRenderer.on('asynchronous-reply', (event, arg) => {
        //     console.log(arg) // prints "pong"
        // })
    }

    /**
     * Removes all ipc listeners.
     */
    static removeAllListeners(): void {
        ipcMain.removeAllListeners();
    }
}